﻿

var g_str_type_1 = "clothing";
var g_str_type_3 = ""; 
var g_str_sex = "0"; 
var g_bool_init_finish = false;


//-------------页面初始化--------------
function initPage()
{
	DisplayObj("btn_edit_all_dress_order_index", "none"); //隐藏修改所有套装排序字段按钮
    GetListType_1();  		//查找一级类
}

//-------------查找分类--------------
function GetListType_1()
{  
	on_select_change_type2()
} 

function on_select_change_type2()
{  
	tmpTypeVal_1 = "clothing";      	    //当前选择类别1
	tmpTypeVal = "";      					//当前选择类别2
	var data = "&typeName_1=" + tmpTypeVal_1;
	data += "&typeName=" + tmpTypeVal;
	PostToPHP(__on_select_change_type2_callback, "info", "query_type_3", data); 
}
function __on_select_change_type2_callback(text)
{
	//alert(text);
	var jsonObj = String2JSON(text);
	var ds = GetDataSet(jsonObj);
	if(ds && ds[0])
	{
        FillSelectObj("type_3", ds[0]);	
		g_bool_init_finish = true;		//初始化成功
		
		DelSelectObjByVal("type_3", "limitcount");
	}
} 

//-------------查询-----------
function on_query()
{ 
	if(!g_bool_init_finish)
		return;
		  
	g_str_type_3 = $("type_3").value;   	//当前三级类
	g_str_sex = $("select_gender").value;   //当前选择查询的性别
	
	CleanConfig(); //清空配置  
        
	 
	//AddItemConfig("id", 0);   
	
	//AddItemConfig("id", 99, "../edit/goods_dress_edit.html?id=", "编辑");
	AddItemConfig("id", 199, "../edit/goods_dress_edit.html?id=", "id");
	
	AddItemConfig("sex", 98, JudgeIsSexTextFunc);
	AddItemConfig("level", 0);
	AddItemConfig("type_3", 0);  
	 
	
	AddItemConfig("cost_goods_id", 0);  
	AddItemConfig("cost_goods_name", 0);  
	AddItemConfig("cost_goods_name_view", 0); 
	AddItemConfig("cost_money", 0);  
	AddItemConfig("cost_gold", 0);  
	//AddItemConfig("filepath", 101, "cost_goods_id", GetSwfFileRootPath(), "_0."+GetFilePostfix(), "sex");
	AddItemConfig("filepath", 298, setImgHref, "cost_goods_id", "sex", "图"); 
	
	AddItemConfig("trousers_goods_id", 0);  
	AddItemConfig("trousers_goods_name", 0);  
	AddItemConfig("trousers_goods_name_view", 0);  
	AddItemConfig("trousers_money", 0);  
	AddItemConfig("trousers_gold", 0);  
	//AddItemConfig("filepath", 101, "trousers_goods_id", GetSwfFileRootPath(), "_0."+GetFilePostfix(), "sex");
	AddItemConfig("filepath", 298, setImgHref, "trousers_goods_id", "sex", "图"); 
	
	AddItemConfig("skirt_goods_id", 0);  
	AddItemConfig("skirt_goods_name", 0);  
	AddItemConfig("skirt_goods_name_view", 0);  
	AddItemConfig("skirt_money", 0);  
	AddItemConfig("skirt_gold", 0);  
	//AddItemConfig("filepath", 101, "skirt_goods_id", GetSwfFileRootPath(), "_0."+GetFilePostfix(), "sex"); 
	AddItemConfig("filepath", 298, setImgHref, "skirt_goods_id", "sex", "图"); 
	
	AddItemConfig("id", 202, "1", "checkbox_money", "比索"); 
	AddItemConfig("id", 201, "level", "level"); 
	
	AddItemConfig("id", 2, "editItemFunc", "编辑");
	//AddItemConfig("id", 99, "../edit/goods_dress_edit.html?id=", "编辑");
	
	var _data_1 = "&type_1=" + g_str_type_1;  
		_data_1 += "&type_3=" + g_str_type_3; 
		_data_1 += "&sex=" + g_str_sex;   
	
	SetPagingConfig("paging", "get_goods_dress_total", _data_1, 
					"paging", "get_goods_dress_list", _data_1);
					
	PagingInit(GetDefaultPageCount(), "tbody_query", "div_paging"); 
}
 
function setImgHref(index, filepath, goods_id, sex) //男女 0:女， 1:男
{ 
	if(goods_id)
		return GetSwfFileRootPath() +filepath +  goods_id + "_" + sex + "_0."+GetFilePostfix(); 
	return "";
} 

//--编辑
function editItemFunc(index, id)
{ 
	//if(confirm("是否编辑?") == false) return;
	 
	ckObj = $(id+"_checkbox_money");
	levelObj = $(id+"_level");
	
	var data = "&id=" + id; 
	data += "&level=" + levelObj.value;
	data += "&is_checkbox_money=" + (ckObj.checked ? "1" : "0"); 
	
	//alert(data);
	PostToPHP(__editNoSellFuncCallback, "info", "edit_auto_goods_dress_info", data);
} 
function __editNoSellFuncCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, RePaging);
}

 
function JudgeIsSexTextFunc(index, val) //男女 0:女， 1:男
{
	return val == 0 ? "女" : "男";
} 
 
//编辑所有套装排序字段
function on_edit_all_dress_order_index()
{
	PostToPHP(__on_edit_all_dress_order_indexCallback, "info", "edit_all_dress_order_index", "");
}
function __on_edit_all_dress_order_indexCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, null);
}
